package com.neuedu.his.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neuedu.his.po.Register;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper // 添加这个注解
public interface RegisterMapper extends BaseMapper<Register> {

    @Select("SELECT * FROM register WHERE UserID = #{doctorId} AND VisitState = 1 ORDER BY RegistTime DESC")
    List<Register> getPendingPatients(@Param("doctorId") Integer doctorId);

    @Select("SELECT * FROM register WHERE UserID = #{doctorId} AND VisitState = 2 ORDER BY RegistTime DESC")
    List<Register> getInTreatmentPatients(@Param("doctorId") Integer doctorId);

    @Select("SELECT COUNT(*) FROM register WHERE UserID = #{doctorId} AND ID = #{registId}")
    int countByDoctorAndRegistId(@Param("doctorId") Integer doctorId, @Param("registId") Integer registId);
}